<!DOCTYPE html>
<html class="x-admin-sm">
<html lang="en" xmlns:th="http://wwww.thymeleaf.org" >
<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="../aaa/css/font.css">
    <link rel="stylesheet" href="../aaa/css/xadmin.css">
    <script type="text/javascript" src="../aaa/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../aaa/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form" action="/indent/insert" method="get">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>编号
                </label>
                <input type="text" name="logparticularsid"  th:value="${disneed.logparticularsid}"style="display: none">
                <div class="layui-input-inline">
                    <input type="text" id="ordersId" name="ordersId" required="required" lay-verify="required"
                           autocomplete="off" class="layui-input" th:value="(${disneed.dis_need_id})" >
                </div>
                <label class="layui-form-label">
                    <span class="x-red">*</span>审核状态
                </label>
                <div class="layui-input-inline" >
                    <select name="statusid" class="layui-input-inline" disabled>
                        <option value="0">请选择</option>
                        <option th:each="a:${status}"
                                th:selected="${a.statusid eq disneed.statusid}"
                                th:value="${a.statusid}"
                                th:text="${a.statusname}"></option>
                    </select>
                </div>
                <label class="layui-form-label">
                    <span class="x-red">*</span>单据日期
                </label>
                <div class="layui-input-inline">
                    <input type="text" name="ordertime" class="layui-input" id="test1" placeholder="请选择日期" lay-key="1" th:value="${disneed.birth}" disabled>
                </div>
                <label class="layui-form-label">
                    <span class="x-red">*</span>商品名
                </label>
                <div class="layui-input-inline">
                    <select name="commodityid" class="layui-input-inline">
                        <option value="0">请选择</option>
                        <option th:each="a:${com}"
                                th:selected="${a.commodityid eq disneed.commodityid}"
                                th:value="${a.commodityid}"
                                th:text="${a.commodityname}"></option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>包装数量
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="satypenumber" name="satypenumber" required="required" lay-verify="required"
                           autocomplete="off" class="layui-input" th:value="${disneed.satypenumber}">
                </div>
                <label class="layui-form-label">
                    <span class="x-red">*</span>包装供应商
                </label>
                <div class="layui-input-inline">
                    <select name="BsupId" class="layui-input" >
                        <option value="0">请选择</option>
                        <option th:each="a:${bsu}"
                                th:selected="${a.BsupId eq disneed.BsupId}"
                                th:value="${a.BsupId}"
                                th:text="${a.BsupName}"></option>
                    </select>
                </div>
                <label class="layui-form-label">
                    <span class="x-red">*</span>商品数量
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="Samnumber" name="Samnumber" required="required"
                           class="layui-input" th:value="${disneed.Samnumber}">
                </div>
                <label class="layui-form-label">
                    <span class="x-red">*</span>商品单价
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="coprice" name="coprice" th:value="${disneed.commodity.coprice}" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>包装单价
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="Bsprice" readonly="readonly" name="Bsprice" required="required" lay-verify="pass"
                           autocomplete="off" class="layui-input" th:value="${disneed.Bsupplier.Bsprice}">
                </div>
                <label class="layui-form-label">
                    <span class="x-red">*</span>物流公司
                </label>
                <div class="layui-input-inline">
                    <select name="logId" class="layui-input" >
                        <option value="0">请选择</option>
                        <option th:each="a:${log}"
                                th:selected="${a.logId eq disneed.logId}"
                                th:value="${a.logId}"
                                th:text="${a.logname}"></option>
                    </select>
                </div>
                <label class="layui-form-label">
                    <span class="x-red">*</span>当前地址
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="orloc" name="orloc" required="required" lay-verify="pass"
                           autocomplete="off" class="layui-input" th:value="河南省新乡市红旗区">
                </div>
                <label class="layui-form-label">
                    <span class="x-red">*</span>到达地址
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="arrloc" name="arrloc" required="required" lay-verify=""
                           autocomplete="off" class="layui-input" th:value="${disneed.distributor.distloc}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>应付金额
                </label>
                <div class="layui-input-inline">
                    <input type="text" required="required" lay-verify="pass"  name="advance"
                           autocomplete="off" class="layui-input" th:value="((${disneed.commodity.coprice}*${disneed.Samnumber}+${disneed.Bsupplier.Bsprice}*${disneed.satypenumber})+${disneed.advance})">
                </div>
                <label class="layui-form-label">
                    <span class="x-red">*</span>采购人
                </label>
                <div class="layui-input-inline">
                    <select name="emp_id" class="layui-input" >
                        <option value="0">请选择</option>
                        <option th:each="emp:${emp}"
                                th:value="${emp.emp_id}"
                                th:text="${emp.emp_name}"></option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                    <button  class="layui-btn layui-btn-radius" lay-filter="add" lay-submit="" style="width: 200px;margin-left:550px">
                        增加
                    </button>
            </div>
        </form>
        <table class="layui-table layui-form">
            <thead>
            <tr>
                <th>编号</th>
                <th>分销商</th>
                <th>商品供应商</th>
                <th>商品详情</th>
                <th>包装类别</th>
                <th>包装供应商</th>
                <th>物流公司</th>
                <th>物流方式</th>
                <th>审核状态</th>
                <th>定金</th>
            </thead>
            <tbody>
            <tr th:each="dis_need:${dis_need}">
                <td th:text="${dis_need.dis_need_id}"></td>
                <td th:text="${dis_need.Distributor.distributorname}"></td>
                <td th:text="${dis_need.supplier.supName}"></td>
                <td th:text="${dis_need.commodity.commodityname}"></td>
                <td th:text="${dis_need.Bcategory.Bcategoryname}"></td>
                <td th:text="${dis_need.Bsupplier.BsupName}"></td>
                <td th:text="${dis_need.logistics.logname}"></td>
                <td th:text="${dis_need.logmode.logmodename}"></td>
                <td th:text="${dis_need.statusl.statusname}"></td>
                <td th:text="${dis_need.advance}"></td>
            </tr>
            </tbody>
        </table>
    </div>
</div>
<script>
    layui.use(['form', 'layer','jquery'],
        function() {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;
            //监听提交
            form.on('submit(add)',
                function(data) {
                    console.log(data.field);
                    var datas=data.field;
                    if (datas.status=="on"){
                        datas.status=0;//正常状态
                    }else {
                        datas.status=1;
                    }
                    $.ajax({
                        url: "/indent/insert",
                        type: "POST",
                        data:datas,
                        success: function (result) {

                            if (result.code==200){
                                layer.msg("添加失败");
                            }
                            else {
                                layer.msg("添加成功",{
                                    icon: 6,
                                    time:500
                                },function() {
                                    parent.parent.window.location.reload();//重新页面
                                    // 获得frame索引
                                    var index = parent.layer.getFrameIndex(window.name);
                                    //关闭当前frame
                                    parent.layer.close(index);
                                });
                            }
                        }, error:function (e) {
                            //返回500错误 或者其他 http状态码错误时 需要在error 回调函数中处理了 并且返回的数据还不能直接alert，需要使用
                            //$.parseJSON 进行转译    res.msg 是自己组装的错误信息通用变量
                            var res = $.parseJSON(e.responseText);
                            layer.msg("数据重复，请检查以往单据",{icon:7});
                            return false;
                        }, error:function (e) {
                            //返回500错误 或者其他 http状态码错误时 需要在error 回调函数中处理了 并且返回的数据还不能直接alert，需要使用
                            //$.parseJSON 进行转译    res.msg 是自己组装的错误信息通用变量
                            var res = $.parseJSON(e.responseText);
                            layer.msg("添加失败,检查数据填输是否完整,正确");}
                    });
                    return false;
                });


        });
    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#test1' //指定元素
        });
    });
    /*用户-删除*/
    function member_insert(obj,dis_need_id){
        layer.confirm('确定要添加吗？',function(){
            $.ajax({
                url: "/indent/goAdds?dis_need_id="+dis_need_id,
                type: "POST",
                success: function (result) {
                    window.location.reload();//重新页面

                }
            });
            // $(obj).parents("tr").remove();
            layer.msg('已添加!',{icon:1,time:1000});
        });
    }
</script>
<script>var _hmt = _hmt || []; (function() {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();</script>
</body>

</html>
